//
// Created by lfm on 25-4-15.
//
#include <iostream>
#include <fstream>
using namespace std;

class Person
{
public:
    char m_Name[64];//姓名
    int m_Age; //年龄
};

void test01()
{
    //包含头文件

    //创建流对象
    ifstream ifs;

    //打开文件 判断文件是否打开成功
    ifs.open("person.txt", ios::in | ios::binary);
    //读文件
    if (!ifs.is_open())
    {
        cout << "打开失败" << endl;
        return;
    }
    Person p;
    ifs.read((char*)&p, sizeof(Person));
    cout << "姓名" << p.m_Name << "年龄" << p.m_Age << endl;
    //关闭文件
    ifs.close();
}


int main()
{
    test01();
    return 0;
}